package cn.wolfcode.crm.web.controller;

import cn.wolfcode.crm.domain.StockincomeBill;
import cn.wolfcode.crm.query.StockintcomeBillQueryObject;
import cn.wolfcode.crm.service.IStockincomeBillService;
import cn.wolfcode.crm.util.JsonResult;
import cn.wolfcode.crm.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("stockincomeBill")
public class StockincomeBillController {

    @Autowired
    private IStockincomeBillService service;



    @RequestMapping("")
    public String index() {
        return "stockincomeBill/list";
    }

    @RequestMapping("list")
    @ResponseBody
    public PageResult list(StockintcomeBillQueryObject qo) {
        return service.query(qo);
    }



    @RequestMapping("save")
    @ResponseBody
    public JsonResult save(StockincomeBill stockincomeBill) {
        JsonResult jsonResult = new JsonResult();
        try {
            service.save(stockincomeBill);
            jsonResult.markMsg("操作成功");
        }catch (Exception e){
            e.printStackTrace();
            jsonResult.markMsg("保存失败");
        }
        return jsonResult;
    }
    @RequestMapping("update")
    @ResponseBody
    public JsonResult update(StockincomeBill orderBill){
        JsonResult result = new JsonResult();
        try {
            service.update(orderBill);
            result.markMsg("操作成功");
        }catch (Exception e){
            e.printStackTrace();
            result.markMsg("编辑失败");
        }
        return result;
    }

    @RequestMapping("changeAudit")
    @ResponseBody
    public JsonResult changeAudit(Long id){
        JsonResult result = new JsonResult();
        try {
            service.changeAudit(id);

        }catch (Exception e){
            e.printStackTrace();
            result.markMsg("审核失败");
        }
        return result;
    }

}
